/*
 * $Id$
 *
 * Copyright ( c ) 2014 XuNuo Corporation. All Rights Reserved.
 *
 * This software is the confidential and proprietary information of XuNuo
 * Corporation ("Confidential Information").  You shall not disclose such
 * Confidential Information and shall use it only in accordance with the terms
 * of the license agreement you entered into with XuNuo Corporation or a XuNuo
 * authorized reseller (the "License Agreement"). XuNuo may make changes to the
 * Confidential Information from time to time. Such Confidential Information may
 * contain errors.
 *
 * EXCEPT AS EXPLICITLY SET FORTH IN THE LICENSE AGREEMENT, XuNuo DISCLAIMS ALL
 * WARRANTIES, COVENANTS, REPRESENTATIONS, INDEMNITIES, AND GUARANTEES WITH
 * RESPECT TO SOFTWARE AND DOCUMENTATION, WHETHER EXPRESS OR IMPLIED, WRITTEN OR
 * ORAL, STATUTORY OR OTHERWISE INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A
 * PARTICULAR PURPOSE. XuNuo DOES NOT WARRANT THAT END USER'S USE OF THE
 * SOFTWARE WILL BE UNINTERRUPTED, ERROR FREE OR SECURE.
 *
 * XuNuo SHALL NOT BE LIABLE TO END USER, OR ANY OTHER PERSON, CORPORATION OR
 * ENTITY FOR INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL
 * DAMAGES, OR DAMAGES FOR LOSS OF PROFITS, REVENUE, DATA OR USE, WHETHER IN AN
 * ACTION IN CONTRACT, TORT OR OTHERWISE, EVEN IF XuNuo HAS BEEN ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGES. XuNuo' TOTAL LIABILITY TO END USER SHALL NOT
 * EXCEED THE AMOUNTS PAID FOR THE XuNuo SOFTWARE BY END USER DURING THE PRIOR
 * TWELVE (12) MONTHS FROM THE DATE IN WHICH THE CLAIM AROSE.  BECAUSE SOME
 * STATES OR JURISDICTIONS DO NOT ALLOW LIMITATION OR EXCLUSION OF CONSEQUENTIAL
 * OR INCIDENTAL DAMAGES, THE ABOVE LIMITATION MAY NOT APPLY TO END USER.
 *
 * Copyright version 2.0
 */
package com.th.supcom.pds.deptdispensary.client.widget;

import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;

/**
 * 摆药类型药房配置关系Tab面板
 * 
 * @author 杨冲
 */
public class DispenseTypeTabPanel extends ContentPanel
{
    private DispenseTypeGrid m_dispenseTypeGrid;
    private final DeptVsDispensaryButtons m_buttons;
    private final DeptVsDispensaryFields m_fields;
    private DispenseTypeAction m_action;

    public DispenseTypeTabPanel ()
    {
        m_buttons = new DeptVsDispensaryButtons ();
        m_fields = new DeptVsDispensaryFields ();
        initUI ();
        initAction ();
        initListener ();
        initData ();
    }

    /**
     * 初始化UI
     */
    private void initUI ()
    {
        setHeaderVisible (false);
        setLayout (new FitLayout ());
        initToolBar ();
        initGrid ();
    }

    /**
     * 初始化ToolBar
     */
    private void initToolBar ()
    {
        DispenseTypeToolBar m_dispenseTypeToolBar;
        m_dispenseTypeToolBar = new DispenseTypeToolBar ();
        m_dispenseTypeToolBar.setButtons (m_buttons);
        m_dispenseTypeToolBar.initUI ();
        setTopComponent (m_dispenseTypeToolBar);
    }

    /**
     * 初始化Grid
     */
    private void initGrid ()
    {
        m_dispenseTypeGrid = new DispenseTypeGrid ();
        add (m_dispenseTypeGrid);
    }

    /**
     * 初始化Listener
     */
    private void initListener ()
    {
        DispenseTypeListener m_dispenseTypeListener;
        m_dispenseTypeListener = new DispenseTypeListener ();
        m_dispenseTypeListener.setAction (m_action);
        m_dispenseTypeListener.setButtons (m_buttons);
        m_dispenseTypeListener.setFields (m_fields);
        m_dispenseTypeListener.initListeners ();
    }

    /**
     * 初始化Action
     */
    private void initAction ()
    {
        m_action = new DispenseTypeAction ();
        m_action.setFields (m_fields);
        m_action.setGrid (m_dispenseTypeGrid);
    }

    /**
     * 初始化数据
     */
    private void initData ()
    {
        m_action.refresh ();
    }

}
